package com.leyou.item.mapper;

import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface BrandMapper extends Mapper<Brand> {
    @Insert("insert into tb_category_brand (category_id,brand_id) values (#{cid},#{id})")
    void addCategoryAndBrand(@Param("cid") Long cid, @Param("id") Long id);


    @Delete("delete from tb_category_brand where brand_id=#{id}")
    void deleteCategory(@Param("id") Long id);
    @Select("select tb.id, tb.name, tb.image, tb.letter from tb_brand tb inner join tb_category_brand cb on cb.brand_id = tb.id where cb.category_id = #{cid}")
    List<Brand> queryBrandByCategory(@Param("cid") Long cid);
}
